home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 321 < prev    next >
Encoding:
Text File  |  1996-08-05  |  865 b   |  36 lines

  1. Path: seas.smu.edu!not-for-mail
  2. From: dbowman@post.smu.edu (Damon Bowman)
  3. Newsgroups: comp.lang.c++
  4. Subject: beginner question - typecasting
  5. Date: 3 Jan 1996 12:31:23 -0600
  6. Organization: Southern Methodist University
  7. Sender: usenet@seas.smu.edu
  8. Message-ID: <4cei1r$s02@sun.cis.smu.edu>
  9. Reply-To: dbowman@post.smu.edu
  10. NNTP-Posting-Host: sun.cis.smu.edu
  11. X-Nntp-Posting-Host: ax4-10.ppp.smu.edu
  12. X-Newsreader: Forte Free Agent 1.0.82
  13.  
  14.  
  15. When you are typecasting, is there any difference between:
  16.  
  17. a = int(x)
  18. and
  19. a = (int) x
  20.  
  21. My book (Teach Yourself Visual C++ 1.5 in 21 Days, Revised Edition, by
  22. Shammas) says both forms are supported, but doesnÆt say which should
  23. be used, or if it matters.
  24.  
  25. The specific example given is:
  26.  
  27. int i = 2;
  28. float a, b;
  29. a = float(i);
  30. b = (float) i;
  31.  
  32. In this example, would a and b return the same value and have the same
  33. data type (float)?
  34.  
  35.  
  36.